<?
	$group = $dsfm_common->get_all("common_group");
	$tpl->assign("group", $group);

	$all_assessment = $dsfm_common->get_all("assessment", "year=".$_SESSION['year']. " ORDER by sub ASC");
	$tpl->assign("all_assessment", $all_assessment);

	for($i = 0; $i < 3; $i++){
		$year_range[$i]['year'] = $_SESSION['year']-1+$i;
		$year_range[$i]['grand_total'] = 0;

		$all_assessment = $dsfm_common->get_all("assessment", "year=".$year_range[$i]['year']. " ORDER by sub ASC");

		$tmp = array();

		foreach($group as $key => $value){
			foreach($all_assessment as $k => $v){
				if($v['gid'] == $value['id']){
					$tmp[$v['gid']] += $v['evaluation'];
					$year_range[$i]['grand_total'] += $v['evaluation'];
				}
			}
		}
		$year_range[$i]['total'] = $tmp;
	}

	$tpl->assign("total", $year_range);

	$tpl->assign("year",$_SESSION['year']);
	$tpl->draw("graph");
?>